package com.ruoyi.eqmonitor.service;

import java.text.ParseException;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

import com.ruoyi.eqmonitor.domain.OptDevice;
import com.ruoyi.eqmonitor.domain.OptDeviceAlarm;

import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.eqmonitor.domain.OptDeviceMonitorConfig;
import com.ruoyi.eqmonitor.dtos.*;
import com.ruoyi.eqmonitor.vo.BszsVo;
import com.ruoyi.eqmonitor.vo.CsyzVo;
import com.ruoyi.eqmonitor.vo.ReportCVo;

/**
 * @author ruoyi
 * @date 2022-11-25
 */
public interface IOptDeviceAlarmService extends IService<OptDeviceAlarm>{

    public OptDeviceAlarm selectOptDeviceAlarmById(Long id);

    public List<OptDeviceAlarm> selectOptDeviceAlarmList(AlarmSearchInput optDeviceAlarm);

    List<OptDeviceAlarmDto> listAndDispatch(AlarmSearchInput optDeviceAlarm);

    List<OptDeviceAlarmDto> newestList(AlarmSearchInput dto) throws ParseException;
    /**
     * 运维管理使用 -- 按时间周期搜索
     */
    List<OptDeviceAlarmDto> deviceListAndDispatch(AlarmSearchInput optDeviceAlarm);

    /**
     * 创建报警实体
     * @param device 设备对象
     * @param optDeviceMonitorConfig 阈值配置对象
     * @param monitorData 采集数据值
     */
    public OptDeviceAlarm buildAlarmEntity(OptDeviceDto device,
                                           OptDeviceMonitorConfig optDeviceMonitorConfig,
                                           Double monitorData,
                                           Date alarmTime);

    /**
     * 修改报警记录持续报警状态为false
     * @param deviceCode 设备编码
     * @param alarmType 报警类型
     * @param alarmPhenomenon 报警现象
     * @param alarmCode 一般为监测指标
     */
    public void updatePersistentStatusToFalse(String deviceCode, String alarmType, String alarmPhenomenon, String alarmCode);

    /**
     * 生成报警
     * @param alarm 报警数据
     */
    public void doSaveAlarm(OptDeviceAlarm alarm);

    /**
     * 修改报警当前状态
     */
    public void updatePersistentStatus(OptDeviceAlarm optDeviceAlarm);

    public List<OptDeviceAlarmDto> selectOptDeviceAlarmClogList(OptDeviceAlarmDto dto);

    public OptDeviceAlarmDto selectOptDeviceAlarmClogInfo(Long id);

    public Long mySelectCount(List<String> deviceTypes,List<String> areaCodes,String areaName);

    public List<Map<String, Object>> quantityStatistics(OptDeviceAlarmDto dto);

    /**
     * 修改报警记录状态为清除
     */
    public boolean updateConfirmAlarmToClear(Long alarmId);
    /**
     * 修改报警记录状态为处置中
     */
    public boolean updateConfirmAlarmToInDisposal(Long alarmId);

    /**
     * 查询设备所属污水厂 指定报警现象的最低报警
     * @param deviceCode 设备编码
     * @return 报警
     */
    public OptDeviceAlarmDto minSewageAlarmByDeviceCode(String deviceCode, String alarmPhenomenon);

    /**
     * 查询设备所属污水厂 指定报警现象的最高报警
     * @param deviceCode 设备编码
     * @return 报警
     */
    public OptDeviceAlarmDto maxSewageAlarmByDeviceCode(String deviceCode, String alarmPhenomenon);

    List<CsyzVo> selectCsyzBackstage(CsyzVo query);

    List<BszsVo> selectBSZSBackstage(BszsVo query);

    Map<String, Object> selectYWSZBJ();

    List<OptDeviceAlarmDto> selectRiverwayAlarm(RiverwayAlarmDto dto);

    List<OptDevice> backstageDeviceCall(Integer state, BszsVo query);

    ReportCVo report(WordReportDto dto) throws ParseException;

    int countAlarm(String siteId, LocalDateTime startTime,LocalDateTime endTime);
}
